<!doctype html>

<html>

<head>
<meta charset="UTF-8">
<title>sign in</title>
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<style>

        body{
        
            background-color: #97CBFF;
           
           }



div{
    
    background:#009FCC;
   
    font-size:24px;
   
    padding:5px;
    
    color:white;

}
form{
   
      background: #97CBFF ;
  
      border:#357FC4 solid 1px;
    
      color:#575454;  
   
      width:400px;
    
      margin:20px auto;
    
      font-size:15px;

}

table{
    margin:10px auto;
}
a{
    text-decoration:none;
}

input[type="button"]{
    background:#228B22;
    color:white;
    font-

size:15px;
    font-weight:bold;
    width:120px;
    height:40px;
}
td:first-

child{
    text-align:right;
    padding:0 5px;
}
td:only-child{
    text-

align:center;
    font-size:12px;
}

span:before{
    content:"* ";
    color:red;
}

input[type="text"]:read-only{
    border:#888484 solid 2px;
    

background:#888484;
    font-weight:bold;   
}

input[type="text"]:hover{
    background:#EFD9AC;
}

</style>
<script type="text/javascript">

  $(function(){
	
	  var flag1=false;
	   var flag2=flase;
	   $("auser").click(function(){
		   $("auser").val("").css("color","blank");
	   })
	   
	   
	 $("#auser").blur(function()
	 {
		 var user=$("#auser").val();
		 if(user!=null||user!="")
	 {
	    $.ajax({
		 
		 url: "/username",
		 data:{"username": user},
		 type:"post",
		 success: function(res)
		 {
			 if(res==0)
		     {  flag1=true;
				 }
			 else{
				 $("#auser").val("此用户名已被注册，请重新输入").css("color","red");
			 }
		 }
	 })
	 }
	 })
  
		 $("aapassword").blur(function(){
			
			 var pwd=$("#apassword").val();
			 var cpwd=$("aapassword").val();
			 if(pwd!=null||pwd!="")
				 {
				   if(pwd!=cpwd)
					   {
					      alert("密码不一致,请重新输入!");
					   }		 
				 }
			  $.ajax({
			    	 url: "/insertAccount",
					 data:{"username": tuser,"password": tpassword},
					 type:"post"
			 })
				 
		 })
		 
	 })
	 
       
  
	  
       function insertStudent()
      {
    	  var sid=$("#aid").val();
    	  var name=$("#aname").val();
    	  var sex=$("#asex").val();
    	  var age=$("#aage").val();
    	  var dept=$("#adept").val();
    	  var major=$("#amajor").val();
    	  var grade=$("#agrade").val();
    	  var sschool_length=$("#aschool_length").val();
    	  var address=$("#aaddress").val();
    	  var spol=$("#apol").val();
    	  var nation=$("#anation").val();
    	  var srp=$("#arp").val();
    	  var move=$("#amove").val();
    	  
    		 
    		 $.ajax({
    	    	 url: "/insertStudent",
    			 data:{"sno": sid,"sname": name,"ssex": sex,"sage": age,"sdept": dept,"smajor": major,"sgrade": grade,"school_length": sschool_length,"saddress": address,"spol": spol,"snation": nation,"srp": srp,"smove": move},
    			 type:"post"
    	 })
    	    alert("注册成功!");
      }
  
     
     </script>
</head>

<body>

<form>

<div>注册账号</div>

<table>
    
<tr><td><span>用户名</span></td>
<td><input type="text" name="user" id="auser" placeholder="学号/工号"/></td>
</tr>
   

<tr>
<td>
<span>密码</span></td><td>
<input type="password" name="password" id="apassword"/>
</td>
</tr>
 

<tr>
<td><span>确认密码</span></td>
<td><input type="password" name="password" id="aapassword"/></td>
</tr> 
   
<tr>
<td><span>学号</span></td>
<td><input type="text" name="sno" id="aid"/></td>
</tr>  

<tr>
<td><span>姓名</span></td>
<td><input type="text" name="sname" id="aname"/></td>
</tr>  

<tr>
<td><span>性别</span></td>
<td><input type="text" name="ssex" id="asex"/></td>
</tr>  

<tr>
<td><span>年龄</span></td>
<td><input type="text" name="sage" id="aage"/></td>
</tr> 


<tr>
<td><span>系别</span></td>
<td><input type="text" name="sdept" id="adept"/></td>
</tr>  

<tr>
<td><span>专业</span></td>
<td><input type="text" name="smajor" id="amajor"/></td>
</tr>  

<tr>
<td><span>年级</span></td>
<td><input type="text" name="sgrade" id="agrade"/></td>
</tr>  

<tr>
<td><span>学制</span></td>
<td><input type="text" name="school_length" id="aschool_length"/></td>
</tr>  

<tr>
<td><span>地区</span></td>
<td><input type="text" name="saddress" id="aaddress"/></td>
</tr>  

<tr>
<td><span>政治面貌</span></td>
<td><input type="text" name="spol" id="apol"/></td>
</tr>  

<tr>
<td><span>民族</span></td>
<td><input type="text" name="snation" id="anation"/></td>
</tr>  

<tr>
<td><span>奖惩记录</span></td>
<td><input type="text" name="srp" id="arp"/></td>
</tr>  

<tr>
<td><span>休复转退学标记</span></td>
<td><input type="text" name="smove" id="amove"/></td>
</tr>  

<td colspan="2"><input type="checkbox" checked/>我已看过并接受<a href="#">

《用户协议》</a></td>
</tr>
 
   
<tr>
<td colspan="2"><input type="button" name="submit" value="立即注册" onclick="insertStudent();insertAccount()"/></td>
</tr>

<tr>
<td colspan="2"><input type="button" name="submit" value="返回登录界面"  onclick="location.href='login.html'"/></td>
</tr>

</table>

</form>

</body>

</html>
